package com.designMode.interpreter.nonterminal;

import com.designMode.interpreter.AbstractExpression;
import com.designMode.interpreter.NonterminalExpression;

/**
 * 双目运算符表达式
 */
public abstract class BinaryOperatorExpression extends NonterminalExpression {
    final AbstractExpression left, right;

    public BinaryOperatorExpression(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public boolean equals(AbstractExpression exp) {
        if (exp != null && exp instanceof BinaryOperatorExpression) {
            return left.equals(((BinaryOperatorExpression) exp).left) &&
                    right.equals(((BinaryOperatorExpression) exp).right);
        }
        return false;
    }
}
